package edu.tgc.repository.system;

import java.util.List;
import java.util.UUID;

import org.abyss.common.repository.CommonRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import edu.tgc.entity.system.SysDept;

@Repository
public interface SysDeptRepository extends CommonRepository<SysDept, UUID> {

    public List<SysDept> findByParent(SysDept root);

    public List<SysDept> findByParentId(UUID id);

    public SysDept findByParentIsNull();

   /* @Query(value = "select t from #{#entityName} t  where t.parent.id =?1 and t.startProject=true")
    public List<SysDept> findStartDept(UUID id);*/

    @Query(value = "select t from #{#entityName} t left join t.userPositions up left join up.position.duties d left join up.user u where u.id=?1 and d.codePath=?2")
    public List<SysDept> findByDuty(UUID userId, String duty);

	public SysDept findByName(String deptName);


}
